package com.coolw.data.migrate.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 数据迁移状态枚举定义
 *
 * @author coolw
 * @date 2024/2/21 14:17
 */
@Getter
@AllArgsConstructor
public enum MigrateStatusEnum {

    SUCCESS("00", "全部成功"),
    PART_SUCCESS("01", "部分成功"),
    FAIL("02", "失败");

    private final String code;
    private final String desc;

    public static String getDesc(String code) {
        return Arrays.stream(values())
                .filter(r -> Objects.equals(r.getCode(), code))
                .findFirst()
                .map(MigrateStatusEnum::getDesc)
                .orElse(null);
    }
}
